<template>
  <view v-if="successList.length > 0" class="share">
    <view :class="{ 'share-box': shareState }" @click="handleHiddenShare"></view>
    <view class="share-item" :class="{ 'share-show': shareState }">
      <view class="share-to">
        <text>发布成功</text>
        <image src="/static/images/icon/icon_close_grey.png" @click.stop="handleHiddenShare" />
      </view>
      <view class="content">
        <view class="leftBox">
          <image class="successImg" mode="aspectFill" :src="successList[0].imageSrc"></image>
        </view>
        <view class="rightBox">
          <text class="contentText" style="width:">{{ successList[0].title }}</text>
          <view v-if="tagPopupList" class="tagItemBox">
            <block v-for="(item, index) in tagPopupList" :key="index">
              <view class="tagList">#{{ item.title }}#</view>
            </block>
          </view>
        </view>
      </view>
      <view class="cancel">
        <text @click.stop="lookPublish">查看我的发布</text>
      </view>
    </view>
  </view>
</template>
<script>
import './index.scss'
export default {
  props: {
    successList: {
      type: Array,
      default() {
        return []
      }
    },
    tagPopupList: {
      type: Array,
      default() {
        return []
      }
    },
    from: { type: String, default: 'moment' } // moment: 素材圈首页、mine: 个人主页
  },
  data() {
    return {
      shareState: false
    }
  },
  methods: {
    // 显示
    handleShowShare() {
      this.shareState = true
    },
    // 隐藏
    handleHiddenShare() {
      this.shareState = false
      uni.navigateBack()
    },
    // 查看我的种草发布
    lookPublish() {
      if (this.from === 'moment') {
        this.$navigateTo('/pagesMaterial/user-center/index', {}, 'redirectTo')
      } else {
        uni.navigateBack()
      }

      this.shareState = false
    }
  }
}
</script>
